package com.zhang.family_doctor.enums;

import lombok.Getter;

@Getter
public enum ResponseConstantEnum {

    /**
     * 操作成功
     */
    SUCCESS(200,"操作成功"),

    /**
     * 错误请求
     */
    ERROR(400,"错误请求"),

    /**
     * 请求页面未找到
     */
    NOTFINDERROR(404,"请求页面未找到"),

    /**
     * 系统异常
     */
    SYSERROR(-1, "系统异常");

    //请求响应码
    private final Integer resultCode;

    //请求响应消息
    private final String resultMessage;

    ResponseConstantEnum(Integer resultCode, String resultMessage) {

        this.resultCode = resultCode;
        this.resultMessage = resultMessage;
    }

    public static ResponseConstantEnum get(Integer code) {
        //value()方法可以将枚举类转变为一个枚举类型的数组
        for (ResponseConstantEnum responseConstantEnum : ResponseConstantEnum.values()) {
            if (code == responseConstantEnum.getResultCode()) {
                return responseConstantEnum;
            }
        }
        return ResponseConstantEnum.ERROR;
    }
}
